home *** CD-ROM | disk | FTP | other *** search
- Path: news.lpr.carel.fi!usenet
- From: Ari Lukumies <aril@cmt.lpr.mail.carel.fi>
- Newsgroups: comp.lang.c++
- Subject: Re: unsigned char question
- Date: Fri, 01 Mar 1996 16:34:18 +0200
- Organization: Carelcomp Forest
- Message-ID: <31370AEA.75E@cmt.lpr.mail.carel.fi>
- References: <3136864B.7154@eds.com>
- NNTP-Posting-Host: renoir.cclahti.carel.fi
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Perry Hoekstra wrote:
- >
- > This is a basic question but one I cannot answer. I am using VC++ 2.0
- > and I wish to assign a string to a variable of type UCHAR * (which is an unsigned
- > char within ODBC). The code is as follows
- >
- > UCHAR * server;
- >
- > server = "jmbademo";
- >
- > When I attempt to compile this piece of code, I receive the following error:
- >
- > C:\cgi\Envvars\Envvar.cpp(417) : error C2446: '=' : no conversion from 'char[9]'
- > to 'unsigned char*'
- >
- > In addition, when I try to copy or concatenate with lstrcpy or lstrcat, I receive
- > the following error:
- >
- > C:\cgi\Envvars\Envvar.cpp(432) : error C2664: 'lstrcpyA' : cannot convert
- > parameter 1 from 'unsigned char*' to 'char*'
- >
- > C:\cgi\Envvars\Envvar.cpp(433) : error C2664: 'lstrcatA' : cannot convert
- > parameter 1 from 'unsigned char*' to 'char*'
- >
- > I am taking these code examples straight from Microsoft's examples for ODBC
- > calls in their MSDN CD-ROM (i.e. Static SQL Example). What am I doing wrong or
- > how would you code a SQLConnect call within VC++ 2.0?
- >
- > Thank you
- >
-
- Just cast the parameters, for example:
-
- server = (UCHAR *)"jmbademo";
-
- I know, it's ugly, but MSVC tends to be a little too picky on parameter type
- checking... However, when you explicitly do the cast, the compiler is happy :)
-
- Later,
- AriL
- --
- All my opinions are mine and mine alone.
-